package org.adream.account.controller;

import org.adream.account.entity.TagEntity;
import org.adream.account.service.TagService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * "标签管理"管理模块 跳转页controller
 * @author sl
 *
 */
@Controller
public class TagController {
	
	private static final Logger logger = LoggerFactory.getLogger(TagController.class);
	
	@Autowired
	private TagService tagService;
	
	//标签列表页面
	@RequestMapping(value = "/tagPage")
	public ModelAndView tagView() {
		ModelAndView mv = new ModelAndView("/tag/tag");
		return mv;
	}
	
	//标签添加页面
	@RequestMapping(value = "/tagAddPage")
	public ModelAndView tagAddView() {
		ModelAndView mv = new ModelAndView("/tag/tag_add");
		return mv;
	}
	
	//标签编辑页面
	@RequestMapping(value = "/tagEditPage")
	public ModelAndView tagEditView(String tagId) {
		try {
			ModelAndView mv = new ModelAndView("/tag/tag_edit");
			TagEntity tag = tagService.queryTagById(tagId);
			mv.getModel().put("tag", tag);
			return mv;
		} catch (Exception e) {
			logger.warn("跳转标签编辑页失败:" + e.getMessage());
			return null;
		}
	}
}